package taller2.utils;

import java.io.Serializable;

public class Point implements Serializable{
	private static final long serialVersionUID = 1L;
	private int posX,posY;
	
	public Point(int x, int y){
		this.posX = x;
		this.posY = y;
	}

    //copy contructor
    public Point(Point pos) {
        this.posX = pos.getX();
        this.posY = pos.getY();
    }

    // changes the x-Point
	public void setPos(Point pos) {
		this.posX = pos.getX();
		this.posY = pos.getY();
	}
	
	// returns the x-Point
	public int getX() {
		return posX;
	}

	// changes the x-Point
	public void setX(int posX) {
		this.posX = posX;
	}
	
	// returns the x-Point
	public int getY() {
		return posY;
	}

	// changes the x-Point
	public void setY(int posY) {
		this.posY = posY;
	}

	// returns the first minus the second point
	public Point substract(Point other) {
		return new Point(posX-other.getX(),posY-other.getY());
	}
	
	// returns the first plus the second point
	public Point add(Point other) {
		return new Point(posX+other.getX(),posY+other.getY());
	}
	
	// calculates the norm of the point
	public double norm(){
		return Math.sqrt(Math.pow(posX,2) + Math.pow(posY,2));
	}
}
